package learningThread.syn.synchronizedMethodLockObj.synchronizeException;

public class OperationObj {

    private int num = 0;

    /**
     * 由于线程不同步,所以导致 num值会被修改
     * @param username
     */
    public synchronized  void method(String username){
        System.out.println("begin method:"+Thread.currentThread().getName());
        if ("a".equals(username)) {
            throw new RuntimeException("运行中抛出异常");
        }

        System.out.println("end method:"+Thread.currentThread().getName());
    }
}
